package com.ricci.synergybridge.common;

import static com.ricci.synergybridge.common.ErrorCode.SUCCESS;

/**
 * 返回工具类
 *
 * @author hpRicci
 * @create 2024-02-02 18:34
 */
public class ResultUtils {

    /**
     * 成功
     * @param data 接口返回值
     */
    public static <T> BaseResponse<T> success(T data) {
        return new BaseResponse<>(SUCCESS, data);
    }

    public static BaseResponse error(int code, String message, String description) {
        return new BaseResponse<>(code, message, description);
    }

    public static BaseResponse error(ErrorCode errorCode) {
        return new BaseResponse<>(errorCode);
    }

    public static BaseResponse error(ErrorCode errorCode, String description) {
        return new BaseResponse<>(errorCode.getCode(), errorCode.getMessage(), description);
    }

}
